//
//  ShenPiLiuChengRenYuanTableViewCell.m
//  JuBoCRM
//
//  Created by iMac on 2024/4/7.
//  Copyright © 2024 iningKe. All rights reserved.
//

#import "ShenPiLiuChengRenYuanTableViewCell.h"
#import "NSDate+Helper.h"
@implementation ShenPiLiuChengRenYuanTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (void)setModel:(AllModel *)model{
    _model = model;
    NSDictionary *dataDic = model.modelInfoDictionary;
    [self.headImage sd_setImageWithURL:WebImagePath(GetHandleString(dataDic, @"urlImage")) placeholderImage:HeadImagePlaceholder];
    self.nameLabel.text = GetHandleString(dataDic, @"realname");
    self.timeLabel.text = [NSDate dateStringFromString:GetHandleString(dataDic, @"examineTime") format:@"yyyy-MM-dd HH:mm:ss" toFormat:@"yyyy-MM-dd HH:mm"];
    
    if([GetHandleString(dataDic, @"examineTime") length] > 0){
        self.timeWidth.constant = 135;
    }else{
        self.timeWidth.constant = 0;
    }
    if([GetHandleString(dataDic, @"examineStatus") length] > 0){
        if([GetHandleString(dataDic, @"examineStatus") integerValue] == 0){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"待审核";
            self.statusLabel.textColor = rgba(196, 142, 34, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 1){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"通过";
         
            self.statusLabel.textColor = rgba(51, 196, 34, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 2){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"拒绝";
           
            self.statusLabel.textColor = rgba(255, 0, 0, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 3){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"审核中";
     
            self.statusLabel.textColor = rgba(255, 137, 0, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 4){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"撤回";
           
            self.statusLabel.textColor = rgba(90, 98, 112, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 5){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"未提交";
          
            self.statusLabel.textColor = rgba(184, 184, 184, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 6){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"创建";
            self.statusLabel.textColor = rgba(40, 120, 255, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 7){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"删除";
       
            self.statusLabel.textColor = rgba(184, 184, 184, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 8){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"作废";
     
            self.statusLabel.textColor = rgba(184, 184, 184, 1);
        }else  if([GetHandleString(dataDic, @"examineStatus") integerValue] == 10){
            //        0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流
            self.statusLabel.text = @"忽略";

            self.statusLabel.textColor = rgba(184, 184, 184, 1);
        }
    }else{
        self.statusLabel.text = @"";
    }
    
    if([GetHandleString(dataDic, @"examineStatus") integerValue] == 3){
        self.timeLabel.hidden = YES;
    }else{
        self.timeLabel.hidden = NO;
    }
    
    NSDictionary *remarkDic = [NSDictionary dictionary];
    for (NSDictionary *tempD in model.imageArray) {
        if([GetHandleString(dataDic, @"userId") isEqualToString:GetHandleString(tempD, @"examineUserId")]){
            remarkDic = tempD;
//            break;
        }
    }
    self.remarkLabel.text = GetHandleString(remarkDic, @"remarks");
    
    if(self.remarkLabel.text.length > 0){
        self.remarkLabel.sd_layout
        .leftEqualToView(self.yongHuBackView)
        .topSpaceToView(self.yongHuBackView, 6)
        .rightSpaceToView(self.contentView, 16)
        .autoHeightRatio(0);
        [self setupAutoHeightWithBottomView:self.remarkLabel bottomMargin:6];
    }else{
        self.remarkLabel.sd_layout
        .leftEqualToView(self.yongHuBackView)
        .topSpaceToView(self.yongHuBackView, 0)
        .rightSpaceToView(self.contentView, 16)
        .autoHeightRatio(0);
        [self setupAutoHeightWithBottomView:self.yongHuBackView bottomMargin:6];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
